<template>
  <div id="app">
    <h1 v-text="msg" ref="title"></h1>
    <button @click="showDOM" ref="ref">点我输出上方DOM元素</button>
    <School ref="sch" id="sch"/>
  </div>
</template>

<script>
  /**
   * ref属性性
   * 1.被用来给元系或子组件注册引用信息(id的替代者)
   * 2.应用在htm1标签上获取的是真实DOM元素，应用在组件标签上是组件实例对象(vc)
   * 3.使用方式:
        打标识:<h1 ref="xxx">.....</h1>或<chool ref="xxx"></School>
        获取:this.$refs.xxx
  */
import School from './components/School.vue'

export default {
  name: 'App',
  components: {
    School
  },
  data() {
    return {
      msg:"欢迎学习VUE"
    }
  },
  methods: {
    showDOM(){
      console.log(this.$refs)
      //console.log(this.$refs.sch)//拿到的是School组件的实例对象(vc)
      //console.log(document.getByElementById('sch'))//拿到的是school组件上的所有的DOM元素
    }
  },
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
